Repository navigation
[cpyrt] Detect enum arguments by type in overload priority - #75
Conversation
d9a8c10 to
0770238
Compare
guitargeek
left a comment
There was a problem hiding this comment.
Thanks, this goes in the right direction! pick(2) now returns 2, penalty fires via IsEnumType(GetMethodArgType(...)). One remaining problem though: the penalty is argument-agnostic, so pick(Color.Green) now returns 2: previously 1, and C++ overload resolution would also give 1. An enum object is an exact match for the enum overload.
I think this is a behavioral regression that needs to be fixed and locked in to the unit test.
2002629 to
90724f7
Compare
Makes sense. Since the priority alone can't tell the two calls apart, I've addressed this distinction by moving it into the converter logic itself. By-value enum parameters now get an |
GetPriority() deprioritizes enum arguments so that a competing integer overload wins, since C++ has no implicit int->enum conversion, but it detected them with IsEnumScope(GetScope(name)). GetScope does not resolve an enum name to a scope, so the penalty never applied. Query the argument type with IsEnumType as well, per the existing FIXME. The priority is argument-agnostic, so on its own it also sends an enum instance to the integer overload. Give by-value enum parameters a converter that accepts an instance of the same enum as an exact match in the first resolution round, and have the integer converters defer enum instances to the implicit round, as they already do for bools.
90724f7 to
7d36505
Compare
guitargeek
left a comment
There was a problem hiding this comment.
LGTM! Thanks for addressing my change request
#75 defers enum instances out of the exact round for integer parameters so that an enum overload wins over an integer one. Two cases regress: an implicit construction from the argument runs under kNoImplicit, where the deferred enum -> int step is refused (RooFit::LineColor(kRed) with a TColorNumber(Int_t) parameter), and in the implicit round a class overload constructible from an int-like object is tried before the integer one (TStyle::SetPalette(kGreyScale) picks the TString overload). Let enum instances through the integer gate under kNoImplicit, and resolve overloads in three stages as C++ ranks them: exact matches, standard conversions (kNoImplicit), implicit conversions.
GetPriority() deprioritizes enum arguments so that a competing integer overload wins, since C++ has no implicit int->enum conversion, but it detected them with IsEnumScope(GetScope(name)). GetScope does not resolve an enum name to a scope, so the penalty never applied. Query the argument type with IsEnumType as well, per the existing FIXME.